/*
 * Block comments with details of changes
 */
public class DeleteCRMexamineHandler implements Triggers.handler
{

        public void handle(){
        Map<Id,CRMCheckCustomer__c> oldCrm = (Map<Id,CRMCheckCustomer__c>)Trigger.oldMap;
		
         
        //能删除的Crm考核客户
        List<CRMexamine__c> cms = new List<CRMexamine__c>();
        for(CRMexamine__c c: [select IFCompetitorproduct__c,IFmaccuraproduct__c,Updateopportunity__c,
                                             MissCompetitmessage__c,MissContentProvider__c,Missmaccuraproduct__c,
                                             IFsalesopportunity__c,IFconflict__c,IFinformation__c,CRMCheckCustomer__c
                                             from CRMexamine__c where CRMCheckCustomer__c in:oldCrm.keySet() ])
        {
        		if(!(c.IFCompetitorproduct__c == null &&
                  c.IFmaccuraproduct__c == null &&
                   c.Updateopportunity__c == null &&
                   
                   c.MissCompetitmessage__c == null &&
                   c.MissContentProvider__c == null &&
                   c.Missmaccuraproduct__c == null &&
                   
                   c.IFsalesopportunity__c == null &&
                   c.IFconflict__c == null &&
                   c.IFinformation__c == null 
                  )){
                    if(oldCrm.containsKey(c.CRMCheckCustomer__c)){
                    	CRMCheckCustomer__c cm = oldCrm.get(c.CRMCheckCustomer__c);
                        cm.addError('CRM考核客户已评分，不允许删除CRM考核客户 !');
                        continue;
                    }
                }else{
                	cms.add(c);
                }
        
        }
            if(cms.size()>0)delete cms;
            
    }
}